/**
 * Created by c.y on 2018-3-19
 * 文件说明: 下载文件
 */

function downFile(blob, fileName, fileType) {
  if (window.navigator.msSaveOrOpenBlob) {
    navigator.msSaveBlob(blob, fileName);
  } else {
    let link = document.createElement("a");
    link.href = window.URL.createObjectURL(blob);
    link.download = fileName + fileType;
    // appendChild这个是为了解决火狐浏览器下载的兼容问题，火狐必须append到html中
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
    window.URL.revokeObjectURL(link.href);
  }
}
export default downFile;
